import { studentRoute } from './student';
import { adminRoute } from "@/router/admin.ts";

// 检查导入的路由是否正确
console.log('routers.ts - studentRoute:', studentRoute);
console.log('routers.ts - adminRoute:', adminRoute);

// 确保路由是数组形式
const processedStudentRoutes = Array.isArray(studentRoute) ? studentRoute : [studentRoute];
const processedAdminRoutes = Array.isArray(adminRoute) ? adminRoute : [adminRoute];

console.log('处理后 - 学生路由数量:', processedStudentRoutes.length);
console.log('处理后 - 管理员路由数量:', processedAdminRoutes.length);

export const constantRoute = [
  // 添加根路径重定向到登录页，放在最前面确保优先级最高
  {
    path: '/',
    redirect: '/login'
  },
  //配置路由页面
  {
    path: '/login',
    component: () => import('@/views/login/index.vue'),
    name: 'login',//路由名称
    meta: {
      title: '登陆',
      hidden: true //路由标题是否隐藏
    }
  },
  {
    path: '/404',
    component: () => import('@/views/404/index.vue'),
    name: '404',//路由名称
    meta: {
      title: '404',
      hidden: true //路由标题是否隐藏
    }
  },
  {
    path: '/register',
    component: () => import('@/views/login/Register.vue'),
    name: 'register',
    meta: {
      title: '注册',
      hidden: true
    }
  },
  {
    path: '/forget',
    component: () => import('@/views/login/Forget.vue'),
    name: 'forget',
    meta: {
      title: '忘记密码',
      hidden: true
    }
  },
  // 使用展开运算符将数组路由添加到constantRoute
  ...processedStudentRoutes,
  ...processedAdminRoutes,
];